package com.wuxin.ssm.controller;

import com.wuxin.ssm.entity.Items;
import com.wuxin.ssm.service.ItemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @program: untitled
 * @ClassName ItemsController
 * @description:
 * @author: 刘庆东
 * @create: 2024−11-29 14:13
 * @Version 1.0
 **/
@Controller
//@RequestMapping("/items/")//窄化路径
public class ItemsController {

    @Autowired
    private ItemsService itemsService;

    @RequestMapping("/lists.action")
    public String lists(HttpSession session){
        List<Items> itemsList = itemsService.findAll();
          //存数据
        session.setAttribute("itemsList",itemsList);
        return "redirect:/itemsList.jsp";
    }

    //  <a href="${pageContext.request.contextPath}/deleteItems.action?ids=${item.id}">删除</a>
    @RequestMapping("/deleteItems.action")
    public String delItems(Integer ids){
        System.out.println("==================>"+ids);
        itemsService.delItemsById(ids);

        return "redirect:/lists.action";

    }

}
